@extends('admin/layout/main')
@section('content')
    <link rel="stylesheet" href="{{ asset('/css/admin/role.css') }}">
    @if(\Session::has('msg'))
        <div class="alert alert-success" role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <strong>{{ \Session::get('msg') }}</strong>
        </div>
    @endif
    <a href="{{ url('admin/role/create') }}" class="btn btn-primary" style="float:right;margin-bottom:20px">添加</a>
    <table class="table table-hover">
        <tr>
            <th>权限名称</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        @foreach($list as $key => $item)
            <tr>
                <td>
                    {{ $item->role_name }}
                    @foreach($item->child as $k => $child)
                        <br /><span class="child">└ {{ $child->role_name }}</span> <span class="child">{{ $child->created_at }}</span>
                        <span class="child">
                            <button type="button" class="btn btn-default" aria-label="Left Align" onclick="location.href='{{ url('admin/role/edit/' . $child->id) }}'">
                                <span class="glyphicon glyphicon glyphicon-pencil" aria-hidden="true"></span>
                            </button>

                            <button type="button" class="btn btn-default" aria-label="Left Align" onclick="location.href='{{ url('admin/role/destroy/' . $child->id) }}'">
                                <span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true"></span>
                            </button>

                            <button type="button" class="btn btn-default" aria-label="Left Align" onclick="location.href='{{ url('admin/role/create/' . $child->id) }}'">
                                <span class="glyphicon glyphicon glyphicon glyphicon-plus" aria-hidden="true"></span>
                            </button>
                        </span>
                    @endforeach
                </td>
                <td>{{ $item->created_at }}</td>
                <td>
                    <button type="button" class="btn btn-default" aria-label="Left Align" onclick="location.href='{{ url('admin/role/edit/' . $item->id) }}'">
                        <span class="glyphicon glyphicon glyphicon-pencil" aria-hidden="true"></span>
                    </button>

                    <button type="button" class="btn btn-default" aria-label="Left Align" onclick="location.href='{{ url('admin/role/destroy/' . $item->id) }}'">
                        <span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true"></span>
                    </button>

                    <button type="button" class="btn btn-default" aria-label="Left Align" onclick="location.href='{{ url('admin/role/create/' . $item->id) }}'">
                        <span class="glyphicon glyphicon glyphicon glyphicon-plus" aria-hidden="true"></span>
                    </button>
                </td>
            </tr>
        @endforeach
    </table>
    <?php echo $list->render(); ?>
@endsection